package com.xqls.biz.impl;

import com.xqls.bean.DischargeRealdataBean;
import com.xqls.bean.RainwaterDischargeRealdataBean;
import com.xqls.biz.RemotecontrolBiz;
import com.xqls.dal.model.Remotecontrol;
import com.xqls.server.dto.send.*;
import com.xqls.service.DischargeRealdataService;
import com.xqls.service.RainwaterDischargeRealdataService;
import com.xqls.service.RemotecontrolService;
import com.xqls.thread.SokectSendCyclicBarrierCallable;
import com.xqls.thread.SoketWaitCallable;
import com.xqls.thread.ThreadPoolExecutorUtil;
import com.xqls.util.CommonResult;
import com.xqls.util.ContextUtil;
import com.xqls.util.DictionaryEnums;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;

@Service
public class RemotecontrolBizImpl implements RemotecontrolBiz{
	private static Logger logger = Logger.getLogger(RemotecontrolBizImpl.class);
	@Autowired private RemotecontrolService remoteService;
	@Autowired private DischargeRealdataService dischargeService;
	@Autowired private RainwaterDischargeRealdataService rainwaterService;

	@Override
	public Remotecontrol queryByDeviceNo(String deviceNo) {
		return remoteService.queryByDeviceNo(deviceNo);
	}

	public Remotecontrol selectMaxTimeByDeviceNo(String deviceNo,String remoteType){
		return remoteService.selectMaxTimeByDeviceNo(deviceNo,remoteType);
	}
	public  Remotecontrol selectMaxTime(String remoteType){
		return remoteService.selectMaxTime(remoteType);
	}

	@Override
	public CommonResult editRemote(Remotecontrol remotecontrol) {
		CommonResult commonResult=new CommonResult();
		String [] deviceNos=remotecontrol.getDeviceNo().split(",");
		boolean success=false;
		try {
			for (String deviceno : deviceNos) {
				if(remotecontrol.getRemoteType().equals("discharge")){
					DischargeRealdataBean dischargeRealdataBean=dischargeService.queryByDeviceNo(deviceno);
					if(remotecontrol.getValveSetting()!=null){
						dischargeRealdataBean.setValveSetting(remotecontrol.getValveSetting().toString());
					}
					success=dischargeService.updateDischargeRealdata(dischargeRealdataBean);
				}else if(remotecontrol.getRemoteType().equals("rainwater")){
					RainwaterDischargeRealdataBean rainwaterDischargeRealdataBean=rainwaterService.queryByDeviceNo(deviceno);
					if(remotecontrol.getValveSetting()==DictionaryEnums.OPEN_VALVE.getCode()){
						rainwaterDischargeRealdataBean.setValveSetting("开");
					}else{
						rainwaterDischargeRealdataBean.setValveSetting("关");
					}
					success=rainwaterService.updatetRainwaterDischargeRealdataList(rainwaterDischargeRealdataBean);
				}
			}
		//	String deviceNo=remotecontrol.getDeviceNo();
//			Remotecontrol remote=remoteService.queryByDeviceNo(deviceNo);
//			if(remote==null){
				remotecontrol.setRemoteType(remotecontrol.getRemoteType());
				remotecontrol.setDeviceNo(remotecontrol.getDeviceNo());
				remotecontrol.setRecordingTime(new Date());
				success=remoteService.insertRemote(remotecontrol);
//			}else{
//				//remotecontrol.setRecordingTime(new Date());
//				remotecontrol.setRemoteNo(remote.getRemoteNo());
//				remotecontrol.setDeviceNo(deviceNo);
//				success=remoteService.updateRemote(remotecontrol);
//			}




		} catch (Exception e) {
			logger.error("编辑远程控制设备信息异常",e);
		}
		commonResult.setIsSuccess(success);
		return commonResult;
	}



	 /**
	     * 开关阀门指令发送
	     * @return
	     */
	 public CommonResult sendSwitchValve(Remotecontrol remotecontrol){
		 CommonResult commonResult=new CommonResult();
		 String [] deviceNos=remotecontrol.getDeviceNo().split(",");

		 try {
			 if(deviceNos.length<=0){
				 commonResult.setResultMsg("未选择企业设备");
				 return  commonResult;
			 }
             ExecutorService executor= ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程
			 final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			 ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();
			 AtomicBoolean success = new AtomicBoolean(true);

			 StringBuffer resultMsg=new  StringBuffer();
			for (String deviceNo : deviceNos) {
				String address=deviceNo;
				Integer anger = null;
				if("rainwater".equals(remotecontrol.getRemoteType())&&remotecontrol.getValveSetting() == DictionaryEnums.OPEN_VALVE.getCode()){
					anger = 99;
				}else if("rainwater".equals(remotecontrol.getRemoteType())&&remotecontrol.getValveSetting() == DictionaryEnums.CLOSE_VALVE.getCode()){
					anger=0;
				}else{
					anger = remotecontrol.getValveSetting();
				}

				listCall.add(new SokectSendCyclicBarrierCallable( barrier,"sendSwitchValve",resultMsg,success,address, anger,remotecontrol.getRemoteType(),remotecontrol.getRainwaterOpenLength()));
			}


			 try {
				 executor.invokeAll(listCall);
			 } catch (Throwable e) {
				 logger.error("开关阀门发送指令异常",e);
			 } finally {
				 executor.shutdown();
			 }
			 commonResult.setIsSuccess(success.get());
			 if(success.get()){
				 editRemote(remotecontrol);
			 }else {

				 commonResult.setResultMsg(resultMsg.toString());
			 }

		} catch (Exception e) {
			logger.error("开关阀门发送指令异常",e);
		}
		 return commonResult;
	 }


	 /**
	     * 采样仪采样设置
	     * @return
	     */
	 public CommonResult samplingSetSend(Remotecontrol remotecontrol){
		 String sendType="samplingSetSend";
		 CommonResult commonResult=new CommonResult();
		 String [] deviceNos=remotecontrol.getDeviceNo().split(",");

		 SamplingSetDto dto ;
		 ConcentrationSamplingSetDto dto2 ;
		 SpecialSamplingSetDto dto3 ;
		 SingleSampleSamplingSetDto dto4;
		 try {
			 if(deviceNos.length<=0){
				 commonResult.setResultMsg("未选择企业设备");
				 return  commonResult;
			 }

			 ExecutorService executor= ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程

			 final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			 ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();
			 AtomicBoolean success = new AtomicBoolean(true);

			 StringBuffer resultMsg=new  StringBuffer();


			if(remotecontrol.getRemoteType().equals("discharge") || remotecontrol.getRemoteType().equals("stormwater")){

				for (String deviceNo : deviceNos) {
					dto=new SamplingSetDto();
					dto.setAdress(deviceNo);
					dto.setWater(remotecontrol.getSingleSamplingQuantity());
					dto.setBigCycle(remotecontrol.getSamplingTotaltime());
					dto.setPercent(remotecontrol.getValveSetting());
	//samplingSetDto(采样仪参数设置)

					  if(remotecontrol.getSamplingMode().equals(DictionaryEnums.SINGLE_SAMPLE_IMMEDIATELY.getCode().toString())){
						//SingleSampleSamplingSetDto(即时单次采样)
						dto4=new SingleSampleSamplingSetDto();
						dto4.setAdress(deviceNo);
						dto4.setSamplingBottle(remotecontrol.getSamplingBottle());
						dto4.setSingleSamplingQuantity(remotecontrol.getSingleSamplingQuantity());
						listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remotecontrol,dto4,sendType,remotecontrol.getRemoteType()));
					}else{
					if(DictionaryEnums.RESTART_NOW.getCode().equals(remotecontrol.getStartupMode())){
						dto.setDelayedStar(8888);
					}else{
						dto.setDelayedStar(remotecontrol.getDelayed());
					}
					if(remotecontrol.getSamplingMode()!=null&&!remotecontrol.getSamplingMode().equals(DictionaryEnums.CONCENTRATION_TRIGGER.getCode().toString())){
					if(remotecontrol.getSamplingMode().equals(DictionaryEnums.PERIODIC_SAMPLING.getCode().toString())){
						dto.setPeriodicMode(SamplingSetDto.MODEL_PERIODIC);
						dto.setCycle(remotecontrol.getSamplingInterval());
						if(remotecontrol.getCumulativeFlow() != null){
							dto.setThreshold(remotecontrol.getCumulativeFlow());
						}else{
							dto.setThreshold(0);
						}
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.WHOLE_POINT_SAMPLING.getCode().toString())){
						dto.setPeriodicMode(SamplingSetDto.MODEL_PUNCTUALITY);
						dto.setThreshold(remotecontrol.getCumulativeFlow());
						dto.setCycle(remotecontrol.getSamplingInterval());
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.FLOW_ACCUMULATION_SAMPLING.getCode().toString())){
						dto.setPeriodicMode(SamplingSetDto.MODEL_ACCUMULATE);
						dto.setCycle(remotecontrol.getSamplingInterval());
						dto.setThreshold(remotecontrol.getCumulativeFlow());
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.INSTANTANEOUS_FLOW_TRIGGERING.getCode().toString())){
						dto.setPeriodicMode(SamplingSetDto.MODEL_INSTANTANEOUS);
						dto.setThreshold(remotecontrol.getCumulativeFlow());
						dto.setCycle(remotecontrol.getSamplingInterval());
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.LEVEL_TRIGGER.getCode().toString())){
						dto.setPeriodicMode(SamplingSetDto.MODEL_LEVEL);
						dto.setThreshold(remotecontrol.getCumulativeFlow());
						dto.setCycle(remotecontrol.getSamplingInterval());
					}
		
						listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remotecontrol,dto,sendType,remotecontrol.getRemoteType()));

					}
		//	ConcentrationSamplingSetDto		(浓度触发采样参数设置)
						  else{

                          dto2=new ConcentrationSamplingSetDto();

						dto2.setAdress(deviceNo);
						dto2.setWater(remotecontrol.getSingleSamplingQuantity());
						dto2.setBigCycle(remotecontrol.getSamplingTotaltime());

						dto2.setUnknown(9);
						dto2.setUnknown1(0);
						dto2.setTemperature(remotecontrol.getTemperature());
						dto2.setExceedStandard(remotecontrol.getExceedStandard());
						if(remotecontrol.getSampling().equals(DictionaryEnums.N_SAMPLING.getCode())){
							dto2.setSampling(0);
						}else if(remotecontrol.getSampling().equals(DictionaryEnums.FIXED_SAMPLING.getCode())){
							dto2.setSampling(1);
						}else if(remotecontrol.getSampling().equals(DictionaryEnums.PROPORTION_SAMPLING.getCode())){
							dto2.setSampling(2);
						}
						if(DictionaryEnums.RESTART_NOW.getCode().equals(remotecontrol.getStartupMode())){
							dto2.setDelayedStar(8888);
						}else{
							dto2.setDelayedStar(remotecontrol.getDelayed());
						}
						dto2.setPeriodicMode(ConcentrationSamplingSetDto.MODEL_CONCENTRATION);
						dto2.setPH(remotecontrol.getPh());
						dto2.setUV(remotecontrol.getCod());
						dto2.setCycle(remotecontrol.getSamplingInterval());
						dto2.setHt_NH3_N(ht(remotecontrol.getNh3N()*100));
						dto2.setBt_NH3_N(bt(remotecontrol.getNh3N()*100));
						dto2.setSS(remotecontrol.getSs());
			
						listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remotecontrol,dto2,sendType,remotecontrol.getRemoteType()));

					}
					  }
				}
		//SpecialSamplingSetDto	(特殊采样参数设置)
			}else if(remotecontrol.getRemoteType().equals("rainwater")){
				for (String deviceNo : deviceNos){
					dto3=new SpecialSamplingSetDto();
					dto3.setSingleSamplingQuantity(remotecontrol.getSingleSamplingQuantity());
					dto3.setSamplingInterval(remotecontrol.getSamplingInterval());
					dto3.setAdress(deviceNo);
					dto3.setUnknown(10);
					dto3.setSamplingTime(3);
					dto3.setRetain(0);
					dto3.setRetain1(0);
					dto3.setRetain2(0);
					dto3.setRetain3(0);
					dto3.setRetain4(10);
					dto3.setRetain5(10);
					dto3.setFakeAction(0);
					dto3.setAccumulationFlow(0);
					dto3.setAlarm(0);
					dto3.setSensor(0);
					dto3.setSamplingBottles(8);
					dto3.setSingleCapacity(500);
					dto3.setCapacityConstraints(1);
					dto3.setTimeLimit(0);
					dto3.setSimultaneousNumber(remotecontrol.getRainwaterSamplingNumber());
					if(remotecontrol.getSamplingMode().equals(DictionaryEnums.NO_SAMPLING.getCode().toString())){
						dto3.setSamplingMethod(SpecialSamplingSetDto.SAMPLING_NOT);
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.MIXED_SAMPLING.getCode().toString())){
						dto3.setSamplingMethod(SpecialSamplingSetDto.SAMPLING_BLEND);
					}else if(remotecontrol.getSamplingMode().equals(DictionaryEnums.BOTTLE_SAMPLING.getCode().toString())){
						dto3.setSamplingMethod(SpecialSamplingSetDto.SAMPLING_BOTTLE);

					}
		
					listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remotecontrol,dto3,sendType,remotecontrol.getRemoteType()));
				}
			}

		
			 try {
				 executor.invokeAll(listCall);
			 } catch (Throwable e) {
				 logger.error("采样仪采样设置异常",e);
			 } finally {
				 executor.shutdown();
			 }
			 commonResult.setIsSuccess(success.get());
			 if(success.get()){
				 editRemote(remotecontrol);
			 }else {
			
				 commonResult.setResultMsg(resultMsg.toString());
			 }
		 } catch (Exception e) {
			logger.error("采样仪采样设置异常",e);
		}
		 return commonResult;
	 }

	/**
	 * 复位+排空
	 * @param remotecontrol
	 * @return
	 */
	 public CommonResult Reset(Remotecontrol remotecontrol){
		 String sendType="Reset";
		 CommonResult commonResult=new CommonResult();
		 String [] deviceNos=remotecontrol.getDeviceNo().split(",");
		
		 ResetSamplingSetDto dto ;
		 try {
			 if(deviceNos.length<=0){
				 commonResult.setResultMsg("未选择企业设备");
				 return  commonResult;
			 }
			 ExecutorService executor= ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程
		
			 final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			 ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();
			 AtomicBoolean success = new AtomicBoolean(true);

			 StringBuffer resultMsg=new  StringBuffer();
			for (String deviceNo : deviceNos) {
                dto=new ResetSamplingSetDto();

				dto.setAdress(deviceNo);
				dto.setPeriodicMode(ResetSamplingSetDto.MODEL_CONCENTRATION);

				listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remotecontrol,dto,sendType,remotecontrol.getRemoteType()));
			}
		
			 try {
				 executor.invokeAll(listCall);
			 } catch (Throwable e) {
				 logger.error("复位排空接口异常",e);
			 } finally {
				 executor.shutdown();
			 }
			 commonResult.setIsSuccess(success.get());
			 if(!success.get()){
		
				 commonResult.setResultMsg(resultMsg.toString());
			 }

		 } catch (Exception e) {
			logger.error("复位排空接口异常",e);
		}
		 return commonResult;
	 }

	 //时间校准
	 public CommonResult calibration(String deviceNo,Date time,String remoteType){
		 String sendType="calibration";
		 CommonResult commonResult=new CommonResult();
		 String [] deviceNos=deviceNo.split(",");
		 TimeCalibrationSamplingSetDto dto ;
		 try {
			 if(deviceNos.length<=0){
				 commonResult.setResultMsg("未选择企业设备");
				 return  commonResult;
			 }
			 ExecutorService executor= ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程
		
			 ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();
			 final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			 AtomicBoolean success = new AtomicBoolean(true);
	
			 StringBuffer resultMsg=new  StringBuffer();

			for (String device_No : deviceNos) {
				dto=new TimeCalibrationSamplingSetDto();
				dto.setAdress(device_No);
				dto.setReceive(TimeCalibrationSamplingSetDto.CALIBRATION);
				dto.setCalibrationTime(time);
	
				listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,null,dto,sendType,remoteType));
			}
			
			 try {
				 executor.invokeAll(listCall);
			 } catch (Throwable e) {
				 logger.error("时间校准异常",e);
			 } finally {
				 executor.shutdown();
			 }
			 commonResult.setIsSuccess(success.get());
			 if(!success.get()){
			
				 commonResult.setResultMsg(resultMsg.toString());
			 }
		 } catch (Exception e) {
			logger.error("时间校准异常",e);
		}
		 return commonResult;
	 }

	 public CommonResult valveChange(String deviceNo,String valveSetting,String treatment,
			 String highLevel,String lowLevel,String remoteType){
		 Remotecontrol remoteControl = new Remotecontrol();
		 String sendType="valveChange";
		 String [] deviceNos=deviceNo.split(",");
		
		 ValveChangeDto dto ;
		 CommonResult commonResult=new CommonResult();
		 try {
			 if(deviceNos.length<=0){
				 commonResult.setResultMsg("未选择企业设备");
				 return  commonResult;
			 }
			 ExecutorService executor= ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程
		
			 final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			 ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();

			 AtomicBoolean success = new AtomicBoolean(true);
		
			 StringBuffer resultMsg=new  StringBuffer();

			 for (String device_No : deviceNos) {
                 dto=new ValveChangeDto();
				dto.setAdress(device_No);
				dto.setUnkonw(20);
				dto.setUnkonw1(0);
				remoteControl.setHighLevel(highLevel);
				remoteControl.setLowLevel(lowLevel);
				if(treatment.equals("1")){
					remoteControl.setTreatment("保持原来状态");
					dto.setTreatment(0);
				}else if(treatment.equals("2")){
					remoteControl.setTreatment("阀门关");
					dto.setTreatment(55);
				}else if(treatment.equals("3")){
					remoteControl.setTreatment("阀门开");
					dto.setTreatment(99);
				}
				if(valveSetting.equals("1")){
					remoteControl.setControlModel("远程控制");
					dto.setPeriodicMode(ValveChangeDto.LONG_RANGE);
					dto.setHighLevel(Integer.valueOf(0));
					dto.setLowLevel(Integer.valueOf(0));
				}else if(valveSetting.equals("2")){
					remoteControl.setControlModel("自动控制");
					dto.setPeriodicMode(ValveChangeDto.AUTO_MATIC);
					dto.setHighLevel(Integer.valueOf(highLevel));
					dto.setLowLevel(Integer.valueOf(lowLevel));
				}else if(valveSetting.equals("3")){
					remoteControl.setControlModel("本地控制");
					dto.setPeriodicMode(ValveChangeDto.MANUAL);
					dto.setHighLevel(Integer.valueOf(0));
					dto.setLowLevel(Integer.valueOf(0));
				}
		
				 listCall.add(new SokectSendCyclicBarrierCallable( barrier,"samplingSetSend",resultMsg,success,remoteControl,dto,sendType,remoteType));

			 }
		
			 try {
				 executor.invokeAll(listCall);
			 } catch (Throwable e) {
				 logger.error("阀门控制异常",e);
			 } finally {
				 executor.shutdown();
			 }

			 // 这句是在所有线程都跑完之后才会执行

			 commonResult.setIsSuccess(success.get());
			 if(!success.get()){
			
				 commonResult.setResultMsg(resultMsg.toString());
			 }
		 } catch (Exception e) {
			logger.error("阀门控制异常",e);
		}
		 return commonResult;
	 }
	 
	 /**
	  * 获取数字的个位和十位
	  * @param i
	  * @return
	  */
	 public Integer bt(Integer i){
		 
			int g=i%10;//个位
			int w=(i/10)%10;//十位
			//int b=(i/100)%10;//百位
			//int q=(i/1000)%10;//千位
			String gg=""+g;
			String ww=""+w;
			String bt=ww+gg;
			
		return Integer.valueOf(bt); 
	 }
	 
	 /**
	  * 获取数字的百位和千位
	  * @param i
	  * @return
	  */
	 public Integer ht(Integer i){
		 
			//int g=i%10;
			//int w=(i/10)%10;
			int b=(i/100)%10;
			int q=(i/1000)%10;
			String bb=""+b;
			String qq=""+q;
			String ht=qq+bb;
			
			
		return Integer.valueOf(ht); 
	 }


	@Override
	public CommonResult waitResponse(Remotecontrol remotecontrol, String waitType) {
		String [] deviceNos=remotecontrol.getDeviceNo().split(",");
		CommonResult commonResult=new CommonResult();
		try {
			if (deviceNos.length <= 0) {
				commonResult.setResultMsg("未选择企业设备");
				return commonResult;
			}
			ExecutorService executor = ThreadPoolExecutorUtil.getExcutor(deviceNos.length);//执行线程

			final CyclicBarrier barrier = new CyclicBarrier(deviceNos.length);//执行线程栅栏
			ArrayList<Callable<Void>> listCall = new ArrayList<Callable<Void>>();

			AtomicBoolean success = new AtomicBoolean(true);

			StringBuffer resultMsg = new StringBuffer();
			Integer value=null;
			String  remoteType=remotecontrol.getRemoteType();
			Boolean isSamplingSet=false;
			switch (waitType){
				case "SamplingSet":
					isSamplingSet=true;
					//0空闲，1启动 现在是空闲的  要转变成启动的
					value=1;
					break;
				case "SamplingRest":
					isSamplingSet=true;
					//0空闲，1启动 现在是启动的 要转成空闲的
					value=0;
					break;
				case "ValueSet":
					Integer anger = null;
					if("rainwater".equals(remoteType)&&remotecontrol.getValveSetting() == DictionaryEnums.OPEN_VALVE.getCode()){
						value = 99;
					}else if("rainwater".equals(remoteType)&&remotecontrol.getValveSetting() == DictionaryEnums.CLOSE_VALVE.getCode()){
						value=0;
					}else{
						value = remotecontrol.getValveSetting();
					}
					break;

			}
			for (String device_No : deviceNos) {
				listCall.add(new SoketWaitCallable(barrier, resultMsg, success, device_No, isSamplingSet,value));
			}
			try {
				executor.invokeAll(listCall);
			} catch (Throwable e) {
				logger.error("等待操作结果异常",e);
			} finally {
				executor.shutdown();
			}
			commonResult.setIsSuccess(success.get());
			if(!commonResult.getIsSuccess()){
				commonResult.setResultMsg(resultMsg.toString());
			}
		}catch (Exception e){
			logger.error("等待操作结果异常",e);
			commonResult.setResultMsg("等待操作结果异常");
		}

		return commonResult;
	}
}
